﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Collections.Generic;

namespace CodeCounsel.SharePoint.RibbonDesigner.View.AttachedBehaviors
{
    static class DragDropManagerFactory
    {
        public static bool IsSupportedDragSource(DependencyObject source)
        {
            return source is ItemsControl ||
                source is ContentControl;
        }

        public static bool IsSupportedDropTarget(DependencyObject target)
        {
            return target is ItemsControl ||
                target is ContentControl;
        }

        public static DragManager CreateDragSourceHelper(
            DependencyObject source, Visual originalSource, IDragProcessor dragProcessor)
        {
            if (source is ItemsControl)
            {
                return new ItemsControlDragManager((ItemsControl)source, originalSource, dragProcessor);
            }
            else if (source is ContentControl)
            {
                return new ContentControlDragManager((ContentControl)source, dragProcessor);
            }
            throw new ApplicationException("Unrecognized source");
        }

        public static DropManager CreateDropTargetHelper(DependencyObject target, IDropProcessor dropProcessor)
        {
            if (target is ItemsControl)
            {
                return new ItemsControlDropManager((ItemsControl)target, dropProcessor);
            }
            else if (target is ContentControl)
            {
                return new ContentControlDropManager((ContentControl)target, dropProcessor);
            }
            throw new ApplicationException("Unrecognized target");
        }
    }
}
